home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / mac / files / ant_nec / postproc.z / postproc
Internet Message Format  |  1996-06-25  |  11KB

  1. From boyer@rd.eng.bbc.co.uk Mon Nov 15 06:29:00 1993
  2. From: john.boyer@rd.eng.bbc.co.uk (John Boyer)
  3. Subject: Homebrew NEC post pro
  4. To: nec-list@ee.ubc.ca
  5. Date: Mon, 15 Nov 1993 14:11:49 +0000 (GMT)
  6. X-Mailer: ELM [version 2.4 PL21]
  7. Content-Type: text
  8. Content-Length: 10826
  9. Status: RO
  10. X-Lines: 466
  11.  
  12. Here is the post pro I wrote in Quick Basic for the PC, it requires a
  13. configuration file called config.dat, which must reside in the same
  14. directory is the prog, and looks like this:-
  15.  
  16. polar
  17. both
  18. HRP
  19. c:\needs\nec
  20. .out
  21.  
  22. The prog should just load into quick basic and run.
  23. The config.dat file just sets where things are. I know it's not pretty, but
  24. when you have a prog that works why bother doing anything else to it.
  25. I also know that it only does polar plots, but again that's all I use. The
  26. only redeeming feature of this prog is that it is dead easy and quick to
  27. use. Hope someone finds it useful.
  28.  
  29.  
  30. PS  Spot the hidden feature!  J.B.
  31.  
  32. this is the prog
  33.  
  34. ' Plots patterns from NEC output files
  35. ' Ver 2.92 6/9/93 John Boyer
  36. ' boyer@rd.eng.bbc.co.uk
  37. DECLARE SUB dsplay (d, scale.f, sc.f, graph.type$, what$, cut$, ang.offset)
  38. DECLARE SUB drawsit (graph.type$, what$, cut$, path$, extn$)
  39. DECLARE SUB plotter (f$, path$, sc.f, scale.f, ang.offset, what$)
  40. DECLARE SUB freader.bas (graph.type$, what$, cut$, path$, extn$, f$)
  41. DECLARE SUB sort (lne$, graph.type$, what$, cut$)
  42. DECLARE SUB config (option$, graph.type$, what$, cuts$, path$, extn$)
  43. DECLARE SUB fmax (scale.f, graph.type$, what$, cut$, path$, extn$)
  44. DECLARE SUB dur (path$, extn$, f$)
  45. 'array for pattern data
  46. DIM SHARED values(3, 400)
  47.  
  48. WHILE 2 > 1
  49. CLS
  50. option$ = ""
  51. PRINT , "'D'isplay pattern from nec output file"
  52. PRINT , "'C'hange program defaults"
  53. PRINT , "'Quit"
  54.  
  55. WHILE option$ = ""
  56.  option$ = UCASE$(INKEY$)
  57. WEND
  58.  
  59. SELECT CASE option$ <> ""
  60.  
  61.        CASE option$ = "D"
  62.            drawsit graph.type$, what$, cut$, path$, extn$
  63.  
  64.        CASE option$ = "C"
  65.            config option$, graph.type$, what$, cut$, path$, extn$
  66.  
  67.        CASE option$ = "Q"
  68.            END
  69.  
  70. END SELECT
  71.  
  72. WEND
  73.  
  74. SUB config (option$, graph.type$, what$, cut$, path$, extn$)
  75.  
  76. ' FIle that holds configuration
  77. conf$ = "c:\needs\jgraps\config.dat"
  78. menu$ = ""
  79.  
  80. CLS
  81. 'some options
  82. 'graph.type :- polar-lin lin-lin
  83. 'what :- vp hp both
  84. 'cut :- HRP VRP
  85.  
  86.  
  87.  
  88. 'this bit gets existing config
  89. OPEN conf$ FOR INPUT AS #8
  90. INPUT #8, graph.type$
  91. INPUT #8, what$
  92. INPUT #8, cut$
  93. INPUT #8, path$
  94. INPUT #8, extn$
  95. CLOSE #8
  96.  
  97. 'options menu
  98. IF option$ <> "C" THEN GOTO fin
  99. CLS
  100. PRINT , "The existing configuation is...."
  101. PRINT
  102. PRINT , "'T'race to be plotted is "; what$
  103. PRINT , "'C'ut is "; cut$
  104. PRINT , "'P'ath for files "; path$
  105. PRINT , "'F'ile extension "; extn$
  106. PRINT
  107. PRINT , "Hit key for option"
  108.  
  109. WHILE menu$ = ""
  110.    menu$ = UCASE$(INKEY$)
  111. WEND
  112. option$ = ""
  113.  
  114. IF menu$ = "F" THEN
  115.    option$ = "@"
  116.    menu$ = ""
  117.    INPUT "Enter new default file extension"; extn$
  118. END IF
  119.  
  120. IF menu$ = "P" THEN
  121.    option$ = "@"
  122.    menu$ = ""
  123.    INPUT "Enter new default path"; path$
  124. END IF
  125.  
  126. CLS
  127. PRINT
  128. SELECT CASE menu$ <> ""
  129.        CASE menu$ = "T"
  130.            PRINT , , "'H'orizontal"
  131.            PRINT , , "'V'ertical"
  132.            PRINT , , "'B'oth"
  133.            PRINT
  134.            PRINT "Hit key for option "
  135.  
  136.        CASE menu$ = "C"
  137.            PRINT , , "H'o'rizontal radiation pattern"
  138.            PRINT , , "Ver't'ical radiation pattern"
  139.            PRINT
  140.            PRINT "Hit key for option "
  141. END SELECT
  142.  
  143.  
  144. WHILE option$ = ""
  145.   option$ = UCASE$(INKEY$)
  146. WEND
  147.  
  148.  
  149. SELECT CASE option$ <> ""
  150.  
  151.       CASE option$ = "P"
  152.           graph.type$ = "polar"
  153.       CASE option$ = "a"
  154.           graph.type$ = "lpolar"
  155.       CASE option$ = "L"
  156.           graph.type$ = "linear"
  157.       CASE option$ = "H"
  158.           what$ = "hp"
  159.       CASE option$ = "V"
  160.           what$ = "vp"
  161.       CASE option$ = "B"
  162.           what$ = "both"
  163.       CASE option$ = "O"
  164.           cut$ = "HRP"
  165.       CASE option$ = "T"
  166.           cut$ = "VRP"
  167.  
  168. END SELECT
  169.  
  170. 'This saves new config
  171. OPEN conf$ FOR OUTPUT AS #8
  172. PRINT #8, graph.type$
  173. PRINT #8, what$
  174. PRINT #8, cut$
  175. PRINT #8, path$
  176. PRINT #8, extn$
  177. CLOSE #8
  178.  
  179. fin:
  180. END SUB
  181.  
  182. SUB drawsit (graph.type$, what$, cut$, path$, extn$)
  183. SHARED max, sumh, sumv
  184. 'max used for auto scaling sumh and sumv used for mean gain calculation
  185.  
  186. config "", graph.type$, what$, cut$, path$, extn$
  187.  
  188. 'routine to draw pattern on screen
  189.  
  190. 'go and get data from file
  191. freader.bas graph.type$, what$, cut$, path$, extn$, f$
  192. sc.f = 1
  193. ang.offset = 0
  194. olx = 0
  195. oly = 0
  196. fmax scale.f, graph.type$, what$, cut$, path$, extn$
  197.  
  198. here:
  199. 'graphics screen mode
  200. SCREEN 12
  201.  
  202. WHILE k$ <> " "
  203. 'This bit does graticule
  204. FOR g = 1 TO 10
  205.   CIRCLE (320, 240), 200 * g / 10, 5
  206. NEXT g
  207.  
  208. FOR ang = 0 TO 350 STEP 10
  209.   a = ang * .01745
  210.   LINE (320 - SIN(a) * 20, 240 - COS(a) * 20)-(320 - SIN(a) * 200, 240 - COS(a) * 200), 5
  211. NEXT ang
  212.  
  213. 'Now to plot patterns
  214. IF what$ = "vp" THEN d = 2 ELSE d = 0
  215. IF what$ = "hp" THEN d = 3
  216. IF what$ = "both" THEN
  217.    FOR d = 2 TO 3
  218.     dsplay d, scale.f, sc.f, graph.type$, what$, cut$, ang.offset
  219.    NEXT d
  220. ELSE
  221.    dsplay d, scale.f, sc.f, graph.type$, what$, cut$, ang.offset
  222. END IF
  223.  
  224.  
  225. 'PRINT "Any key"
  226. VIEW PRINT 29 TO 30
  227. PRINT "Use < > keys to rotate trace. Space when done. Offset=";
  228. PRINT USING "###.#"; (ang.offset / .0174533);
  229. PRINT " degrees";
  230.  
  231. k$ = ""
  232. WHILE k$ = ""
  233.   k$ = INKEY$
  234. WEND
  235.  
  236. '.08727 is 10 degrees could be made smaller
  237. IF k$ = "." OR k$ = ">" THEN ang.offset = (ang.offset + .08727)
  238. IF k$ = "<" OR k$ = "," THEN ang.offset = (ang.offset - .08727)
  239. IF k$ <> " " AND k$ <> "." AND k$ <> "," AND k$ <> "<" AND k$ <> ">" THEN k$ = " "
  240. IF k$ <> " " THEN CLS
  241. WEND
  242.  
  243. PRINT "Press S to scale trace or space for next option"
  244. k$ = ""
  245. WHILE k$ = ""
  246.   k$ = UCASE$(INKEY$)
  247. WEND
  248. mgv = (sumv * sc.f * sc.f / (max * max * 3.14159))
  249. mgh = (sumh * sc.f * sc.f / (max * max * 3.14159))
  250.  
  251. IF k$ = "M" THEN PRINT "vp "; mgv, "hp "; mgh
  252.  
  253. IF k$ = "M" THEN k$ = ""
  254. WHILE k$ = ""
  255.   k$ = UCASE$(INKEY$)
  256. WEND
  257.  
  258.  
  259. IF k$ = "S" THEN
  260.   s$ = "0"
  261.   DO UNTIL VAL(s$) > 0
  262.    INPUT "Enter new scale factor of trace"; s$
  263.   LOOP
  264.   sc.f = sc.f * VAL(s$)
  265.   PRINT sc.f
  266.   CLS
  267.   GOTO here
  268. END IF
  269.  
  270. PRINT "Press P for HPGL plot or space to end"
  271. k$ = ""
  272. WHILE k$ = ""
  273.   k$ = UCASE$(INKEY$)
  274. WEND
  275. IF k$ = "P" THEN plotter f$, path$, sc.f, scale.f, ang.offset, what$
  276. SCREEN 0
  277. END SUB
  278.  
  279. SUB dsplay (d, scale.f, sc.f, graph.type$, what$, cut$, ang.offset)
  280. SHARED ang.end, ang.step, ang.start
  281. olx = values(1, 1) * .017453 + ang.offset
  282. oly = values(d, 1)
  283.  
  284. FOR a = 2 TO (ang.end - ang.start) / ang.step + 1
  285.    x = values(1, a) * .017453 + ang.offset
  286.    y = values(d, a)
  287.    LINE (320 + (SIN(olx) * oly * scale.f * sc.f), 240 - (COS(olx) * oly * scale.f * sc.f))-(320 + (SIN(x) * y * scale.f * sc.f), 240 - (COS(x) * y * scale.f * sc.f)), d + 12
  288.    olx = x
  289.    oly = y
  290. NEXT a
  291.  
  292. IF (360 - (ang.end - ang.start)) MOD 360 <= 10 THEN
  293.  x = values(1, 1) * .017453 + ang.offset
  294.  y = values(d, 1)
  295.  LINE (320 + (SIN(olx) * oly * scale.f * sc.f), 240 - (COS(olx) * oly * scale.f * sc.f))-(320 + (SIN(x) * y * scale.f * sc.f), 240 - (COS(x) * y * scale.f * sc.f)), d + 12
  296. END IF
  297.  
  298. END SUB
  299.  
  300. SUB dur (path$, ext$, f$)
  301. 'get list of files with right extn
  302. CLS
  303. it$ = path$ + "\*" + ext$
  304. PRINT it$
  305. FILES it$
  306. INPUT "Enter filename "; f$
  307. END SUB
  308.  
  309.   SUB fmax (scale.f, graph.type$, what$, cut$, path$, extn$)
  310. SHARED max, sumh, sumv, ang.step, ang.end
  311.  
  312. PI = ATN(1) * 4
  313.  
  314. max = 0
  315. sumh = 0
  316. sumv = 0
  317. ang.end = 0
  318. ang.step = values(1, 2) - values(1, 1)
  319.  
  320. FOR a = 1 TO 360
  321. 'sum areas
  322.  sumv = sumv + (values(2, a) * values(2, a) * PI * ang.step / 360)
  323.  sumh = sumh + (values(3, a) * values(3, a) * PI * ang.step / 360)
  324.  
  325. 'look for max of either pattern
  326.  IF and.end < values(1, a) THEN ang.end = values(1, a)
  327.  IF max < values(2, a) THEN max = values(2, a)
  328.  IF max < values(3, a) THEN max = values(3, a)
  329. NEXT a
  330.  
  331. scale.f = 200 / max
  332.  
  333. END SUB
  334.  
  335. SUB freader.bas (graph.type$, what$, cut$, path$, extn$, f$)
  336. SHARED pointer
  337. 'read nec output file
  338. flnum = 1
  339. pointer = 1
  340. INPUT "Enter filename"; f$
  341. IF f$ = "" THEN CALL dur(path$, extn$, f$)
  342. filename$ = path$ + "\" + f$ + extn$
  343. PRINT filename$
  344. OPEN filename$ FOR INPUT AS #flnum
  345.  
  346. 'look for start of pattern data
  347. DO WHILE INSTR(LEFT$(line$, 9), "DEGREES") = 0
  348.    LINE INPUT #flnum, line$
  349. LOOP
  350.  
  351. 'get pttern data and put in array
  352. WHILE NOT EOF(flnum)
  353.    LINE INPUT #flnum, line$
  354.    CALL sort(line$, graph.type$, what$, cut$)
  355.    pointer = pointer + 1
  356. '   PRINT line$
  357. WEND
  358.  
  359. CLOSE #flnum
  360.  
  361. END SUB
  362.  
  363. SUB plotter (f$, path$, sc.f, scale.f, ang.offset, what$)
  364. SHARED ang.start, ang.step, ang.end
  365. 'routine to plot pattern to plotter or file
  366.  
  367. SCREEN 0
  368. INPUT "Enter plot filename or Enter to plot"; ff$
  369. filename$ = path$ + "\" + ff$
  370. a = 1
  371. CONST PI = 3.141592654#
  372. CONST dtor = PI / 180
  373. CONST ninety = 90 * dtor
  374. CONST xx = 5300
  375. CONST yy = 3800
  376. CONST radius = 3198
  377.  
  378. 'This bit plots to the file
  379. IF ff$ = "" THEN OPEN "COM1:9600, S, 7, 1, RS, CS65535, DS, CD" FOR RANDOM AS #2
  380. IF ff$ <> "" THEN OPEN filename$ FOR OUTPUT AS #2
  381.  
  382. PRINT "Graticule y/n?"
  383. WHILE g$ = ""
  384.  g$ = UCASE$(INKEY$)
  385. WEND
  386.  
  387. 'Plotter initialisation"
  388. PRINT #2, "IN;SP1;PU"; xx; ","; yy; ";"
  389. PRINT "Plotting to "; filename$
  390.  
  391.  
  392. 'This does graticule
  393. IF g$ = "Y" THEN
  394.  
  395.  FOR g = 10 TO 1 STEP -1
  396.    PRINT #2, "CI"; INT(radius * g / 10); ";"
  397.  NEXT g
  398.  
  399.  FOR ang = 10 TO 350 STEP 20
  400.    a = ang * dtor
  401.    PRINT #2, "PU;PA"; xx - (SIN(a) * radius / 10); ","; yy - (COS(a) * radius / 10); ";"
  402.    PRINT #2, "PD;PA"; xx - (SIN(a) * radius); ","; yy - (COS(a) * radius); ";"
  403.    a = a + 10 * dtor
  404.    PRINT #2, "PU;PA"; xx - (SIN(a) * radius); ","; yy - (COS(a) * radius); ";"
  405.    PRINT #2, "PD;PA"; xx - (SIN(a) * radius / 10); ","; yy - (COS(a) * radius / 10); ";"
  406.  NEXT ang
  407.  
  408. END IF
  409.  
  410.  
  411. 'plot actual radiation pattern
  412. IF what$ = "vp" THEN u = 2 ELSE u = 3
  413. IF what$ = "hp" THEN t = 3 ELSE t = 2
  414. FOR d = t TO u
  415. olx = values(1, 1) * dtor + ang.offset + ninety
  416. oly = values(d, 1)
  417. IF d = 3 THEN PRINT #2, "LT5;"
  418. PRINT #2, "SP2;PU"; xx + (SIN(olx) * oly * scale.f * sc.f * radius / 200); ","; yy + (COS(olx) * oly * scale.f * sc.f * radius / 200); ";"
  419. PRINT #2, "PD"
  420. FOR a = 2 TO ((ang.end - ang.start) / ang.step) + 1
  421.  x = values(1, a) * dtor + ang.offset + ninety
  422.  y = values(d, a)
  423.  PRINT #2, xx + (SIN(x) * y * scale.f * sc.f * radius / 200); ","; yy + (COS(x) * y * scale.f * sc.f * radius / 200); ","
  424.  olx = x
  425.  oly = y
  426. NEXT a
  427.  
  428. IF (360 - (ang.end - ang.start)) MOD 360 <= 10 THEN
  429.   x = values(1, 1) * dtor + ang.offset + ninety
  430.   y = values(d, 1)
  431.   PRINT #2, xx + (SIN(x) * oly * scale.f * sc.f * radius / 200); ","; yy + (COS(x) * oly * scale.f * sc.f * radius / 200); ","
  432. END IF
  433.  
  434. PRINT #2, ";PU;"
  435. NEXT d
  436. CLOSE #2
  437.  
  438. PRINT "Any key."
  439. WHILE a$ = ""
  440.  a$ = INKEY$
  441. WEND
  442.  
  443. 'FOR j = 1 TO 40
  444. ' PRINT values(1, j), values(2, j), values(3, j)
  445. ' INPUT y$
  446. 'NEXT j
  447.  
  448. END SUB
  449.  
  450. SUB sort (lne$, graph.type$, what$, cut$)
  451. SHARED pointer, ang.start
  452. IF lne$ = "" THEN GOTO bye
  453.  
  454. IF what$ <> "log" THEN
  455.   mag$ = MID$(lne$, 75, 15)
  456.   mag2$ = MID$(lne$, 100, 14)
  457. END IF
  458.  
  459. SELECT CASE cut$ <> ""
  460.      CASE cut$ = "HRP"
  461.           ang$ = MID$(lne$, 10, 8)
  462.  
  463.      CASE cut$ = "VRP"
  464.           ang$ = MID$(lne$, 1, 9)
  465.  
  466. END SELECT
  467.  
  468. 'store values in array
  469. values(1, pointer) = VAL(ang$)
  470. values(2, pointer) = VAL(mag$)
  471. values(3, pointer) = VAL(mag2$)
  472. 'PRINT ang$, mag$, mag2$
  473. 'INPUT f$
  474. ang.start = values(1, 1)
  475. bye:
  476. END SUB
  477.  
  478.  
  479.